package com.fhc.view.list

import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp


@Composable
 fun <T> ClickableListItem(
    item: T,
    itemView: @Composable ((T) -> Unit),
    onClick: (T) -> Unit
) {
    var lastClickTime by remember { mutableLongStateOf(0L) }
    Box(
        modifier = Modifier.padding(8.dp)
            .combinedClickable(
                onClick = {
                    val currentTime = System.currentTimeMillis()
                    if (currentTime - lastClickTime > 500L) {
                        lastClickTime = currentTime
                        onClick(item)
                    }
                }
            )
    ) {
        itemView(item)
    }
}